package com.tang.service;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * 模板模式核心，抽象类定义具体的执行流程，控制输入输出，而实现类负责实现就好
 */
public abstract class NetMall {

    protected Logger log = LoggerFactory.getLogger(this.getClass());

    String uId; // 用户ID
    String uPwd; // 用户密码

    public NetMall(String uId, String uPwd) {
        this.uId = uId;
        this.uPwd = uPwd;
    }

    public String generateGoodsPoster(String skuUrl) {
        if (!login(uId, uPwd)) return null; // 1.验证登录
        Map<String, String> reptile = reptile(skuUrl);// 2.爬虫商品
        return createBase64(reptile);
    }

    protected abstract Boolean login(String uId, String uPwd);

    protected abstract Map<String, String> reptile(String skuUrl);

    protected abstract String createBase64(Map<String, String> goodsInfo);

}
